package com.ruoyi.result.other.mapper;

import java.util.List;
import java.util.Map;

import com.ruoyi.result.other.domain.ResultOther;
import com.ruoyi.result.other.domain.dto.ResultOtherDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 其他上传Mapper接口
 *
 * @author ruoyi
 * @date 2025-01-14
 */
@Mapper
public interface ResultOtherMapper
{
    /**
     * 查询其他上传
     *
     * @param id 其他上传主键
     * @return 其他上传
     */
    public ResultOther selectResultOtherById(Long id);

    /**
     * 查询其他上传列表
     *
     * @param resultOther 其他上传
     * @return 其他上传集合
     */
    public List<ResultOther> selectResultOtherList(ResultOtherDTO resultOther);

    /**
     * 新增其他上传
     *
     * @param resultOther 其他上传
     * @return 结果
     */
    public int insertResultOther(ResultOther resultOther);

    /**
     * 修改其他上传
     *
     * @param resultOther 其他上传
     * @return 结果
     */
    public int updateResultOther(ResultOther resultOther);

    /**
     * 删除其他上传
     *
     * @param id 其他上传主键
     * @return 结果
     */
    public int deleteResultOtherById(Long id);

    /**
     * 批量删除其他上传
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteResultOtherByIds(Long[] ids);

    List<ResultOther> selectResultOtherByIds(Long[] ids);

    @Select("SELECT COUNT(*) FROM result_other WHERE sync_status = '是' AND is_deleted = 0")
    long selectCount();

    @Select("SELECT YEAR(obtain_time) as year, COUNT(*) as count FROM result_other " +
            "WHERE is_deleted = 0 " +
            "GROUP BY YEAR(obtain_time) " +
            "ORDER BY year")
    List<Map<String, Object>> countByYear();

    @Select("SELECT YEAR(obtain_time) as year, COUNT(*) as count FROM result_other " +
            "WHERE is_deleted = 0 AND user_id = #{userId} " +
            "GROUP BY YEAR(obtain_time) " +
            "ORDER BY year")
    List<Map<String, Object>> countByYearAndUserId(@Param("userId") Long userId);
}
